<!DOCTYPE html>
<html>
<head>
    <title>js面向对象--寄生(parasitic)构造函数模式</title>
    <meta charset="utf-8"/>
    <script>

        function Person(name, age, job){
            var o = new Object();
            //属性
            o.name = name;
            o.age = age;
            o.job = job;

            o.sayName = function(){
                alert(this.name);
            }
            return o;
        }

       function SpecialArray(){
           //创建数组
           var values = new Array();
           alert(arguments.length);
           alert(arguments[0]);
           //添加值
           values.push.apply(values, arguments);
           //添加方法
           values.toPipedString = function(){
               return this.join("|");
           }
           return values;
       }

       var colors = new SpecialArray("red", "blue", "green");
       alert(colors.toPipedString());
    </script>
</head>
<body>
</body>
</html>